// 1E 
// subheader(command)   PC NO.(FF/单元号)  monitoringTimer(1000) +       
// request data(headDevice + deviceCode + points + fixedValue('00')  + writeData) 
// subheader(response)  endCode(00)       (response data/abnormalCode)

// subheader              response    command
// 00 batch read  bit       80          00
// 01 batch read  word      81          01

// 02 batch write bit       82          02
// 03 batch write word      83          03

// 04 random write bit      84          04
// 05 random write word     85          05

// PC NO. 
// hostStation 'FF'/Station No such as '03'

// wait time up to the completion of reading or writing processing 
// 0000 一直等 infinitely / 0001 - FFFF unit(250ms) '0010' 16*0.25 = 4S (ASCII)
// binary code '1000' 

// endCode 
// normal '00'
// errorCode such as '10',58 = 数据错误, 56 = 设备代码错误
// errorCode + abnormalCode '5B' + '10'


// deviceNumber(4) + deviceCode(2)  
// such as D1234, 1234(decimal) => 4D2(hexadecimal)
// D204 0000 + 2044    (00 means 256)

// symbol   type    deviceCode 
//  X(16=26) B        '2058' 
//  Y(16=26) B        '2059' 
// M(hexadecimal)  B  '204D' 
// S(hexadecimal)  B  '2053'


//   D(hexadecimal)       W        '2044' (hexadecimal)当前值
//   R(hexadecimal)       W        '2052' (hexadecimal)当前值


//  TN       W        '4E54' (hexadecimal)当前值
//  TS       B        '5354' (hexadecimal)触点

//  CN       W        '4E43' (hexadecimal)当前值
//  CS       B        '5343' (hexadecimal)触点

// batchReadInBit(addr,length){CMD:00 + PCNO. + monitoringTime + headDevice + deviceCode + points + fixedValue('00')}
// M100 12bit
// (6400 0000 204D + 0C + 00)   
// 00 FF 1000 64000000 204D 0C 00 || 80 00 + 10 00 01 00 00 00 
// Response  M100-M111 

// batchReadInWord(addr,length){CMD:01 + PCNO. + monitoringTime + headDevice + deviceCode + points + fixedValue('00')}
// Y40 32bit
// (4000 0000 2059 + 02 + 00) 
// 01 FF 1000 20000000 2059 02 00 || 81 00 + 1F 01 00 00 
// Response  1F     01      00      00  (Y40-Y44,Y48为ON)
//  Y47-Y40(0001 1111),Y4F-Y48,Y57-Y50,Y5F-Y58

// batchWriteInBit(addr,length,valueArray){CMD:02 + PCNO. + monitoringTime + headDevice + deviceCode + points + fixedValue('00') + writeData}
// M50 12bit data(0111 0100 0001)   
// (3200 0000 204D + 0C + 00 + 0111 0100 0001)   M50(OFF) --- M61(ON)
// 02 FF 1000 32000000 204D 0C 00 011101000001 || 82 00 

// batchWriteInWord(addr,length,valueArray){CMD:03 + PCNO. + monitoringTime + headDevice + deviceCode + points + fixedValue('00') + writeData}
// D100 3points data(3412 7698 0901) D100-D102  
// (6400 0000 2044 + 03 + 00 + 3412 7698 0901)
// 03 FF 1000 64000000 2044 03 00 341276980901 || 83 00 
// D100 4660 => 1234 =>3412       D102 265 => 109 => 0109 => 0901 

// randomWriteInBit(addr,length,valueArray){CMD:04 + PCNO. + monitoringTime + totalNumber + fixedValue('00') + device1 + deviceCode1 + writeData1(00/01) + device2 + deviceCode2 + writeData2(00/01)}
// 2points: Y60 01, M6 00
// 04 FF 1000 02 00 3000 0000 2059 01 0600 0000 204D 00 || 84 00 正常

// randomWriteInWord(addr,length,valueArray){CMD:05 + PCNO. + monitoringTime + totalNumber + fixedValue('00') + device1 + deviceCode1 + writeData1(CDAB) + device2 + deviceCode2 + writeData2(CDAB)}
// 2points: D22 4660, C22 4660
// 05 FF 1000 02 00 1600 0000 2044 3412 1600 0000 4E43 3412 || 85 00 正常

let command,PCNO,monitoringTimer,requestData

